﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace WpfApp_MvvmWindowBus.Base;

public class Command : ICommand
{

    public event EventHandler? CanExecuteChanged;

    public Action<object?> ExecuteAction;
    public Func<object?, bool>? DoExecuteActionFunc;

    public Command(Action<object?> _ExecuteAction, Func<object?, bool>? doExecuteActionFunc)
    {
        ExecuteAction = _ExecuteAction;
        DoExecuteActionFunc = doExecuteActionFunc;

    }

    public bool CanExecute(object? parameter)
    {
        return DoExecuteActionFunc?.Invoke(parameter) ?? true;
    }

    public void Execute(object? parameter)
    {
        ExecuteAction?.Invoke(parameter);
    }
}
